package com.tong.calculator.common;

import com.tong.calculator.annotation.valid.EnumCheck;
import com.tong.calculator.constant.Constant;
import com.tong.calculator.enums.OrderTypeEnum;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.validation.annotation.Validated;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;


/**
 * 分页查询对象
 * @author lv
 * @version 1.0.0
 */
@Data
@Validated
public class PageQuery {


    @ApiModelProperty(value = "当前页码",example = "1",required = true)
    @NotNull(message = "参数:{current}不能为空")
    @Min(value = 1,message = "参数:{current}必须大于等于1")
    private Integer current;

    @ApiModelProperty(value = "每页显示数量",example = "10",required = true)
    @NotNull(message = "参数:{size}不能为空")
    @Min(value = 1,message = "参数:{size}必须大于等于1")
    private Integer size;

    @ApiModelProperty(value = "搜索关键字",example = "deleteToken")
    private String key;

    @ApiModelProperty(value = "排序方式",example = "1")
    @EnumCheck(enumClass = OrderTypeEnum.class)
    private String orderType = Constant.DEFAULT_PAGE_ORDER_TYPE;

    @ApiModelProperty(value = "排序字段",example = "name")
    private String orderField = Constant.DEFAULT_PAGE_ORDER_FIELD;
}
